package hope.qiniu.pic.qiniu;

import java.io.File;

import hope.qiniu.pic.qiniu.common.ApplicationConfigUtil;

import com.qiniu.api.auth.digest.Mac;
import com.qiniu.api.config.Config;
import com.qiniu.api.io.IoApi;
import com.qiniu.api.io.PutExtra;
import com.qiniu.api.io.PutRet;
import com.qiniu.api.rs.PutPolicy;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main(String[] args) throws Exception {
        Config.ACCESS_KEY = ApplicationConfigUtil.MY_ACCESS_KEY;
        Config.SECRET_KEY = ApplicationConfigUtil.MY_SECRET_KEY;
        Mac mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
        // 请确保该bucket已经存在
        String bucketName = "hope";
        PutPolicy putPolicy = new PutPolicy(bucketName);
        String uptoken = putPolicy.token(mac);
        PutExtra extra = new PutExtra();
        String key = System.currentTimeMillis() + "";
        File file = new File("e://psbCADDB8C3.jpg");
        PutRet ret = IoApi.putFile(uptoken, key, file, extra);
        
    }
}
